use std::env;
use std::process;
static grades: [libc::c_int; 5] = [85, 90, 75, 95, 88];
static NUM_STUDENTS: libc::c_int = 5;
pub fn printGrades(idx: libc::c_int) {
    unsafe {
        libc::printf(b"Student grades:\n\0".as_ptr() as *const libc::c_char);
        libc::printf(
            b"Student %d: %d\n\0".as_ptr() as *const libc::c_char,
            idx,
            grades[(idx - 1) as usize],
        );
    }
}
pub fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() != 2 {
        println!("Usage: {} <index>", args[0]);
        process::exit(1);
    }
    let idx: libc::c_int = args[1].parse().unwrap_or(0);
    if idx < 1 || idx > NUM_STUDENTS {
        println!("Invalid index, should be between 1 and {}", NUM_STUDENTS);
        process::exit(-1);
    }
    unsafe {
        printGrades(idx);
    }
}
